class UserMailer < ActionMailer::Base

  def signup_notification(user)
    setup_email(user)
    @subject    += 'Please activate your new account'  
    @body[:url]  = "http://localhost:3000/activate/#{user.activation_code}"  
  end
  
  def forgot_password(user)
    setup_email(user)
    @subject    += 'You have requested to change your password'
    @body[:url]  = "http://localhost:3000/reset_password/#{user.password_reset_code}" 
  end
 
  def reset_password(user)
    setup_email(user)
    @subject    += 'Your password has been reset.'
  end
  
  def group_invitation(invitation)
    @recipients  = "#{invitation.email}"
    @from        = "auth.app@bryanbuchs.com"
    @subject     = "auth.app - You have an invitation to join a group"
    @sent_on     = Time.now
    @body[:url]  = "http://localhost:3000/invite/#{invitation.key}"
    @body[:invitation] = invitation
  end
  
  protected
    def setup_email(user)
      @recipients  = "#{user.email}"
      @from        = "auth.app@bryanbuchs.com"
      @subject     = "auth.app - "
      @sent_on     = Time.now
      @body[:user] = user
    end
end